package com.chengcang.api.modules.busi.vo;

import com.chengcang.api.modules.busi.dto.BusiAddressDTO;
import com.chengcang.api.modules.busi.dto.BusiInvoiceHeadDTO;
import com.chengcang.api.modules.busi.dto.orderSnapshotDTO.BusiOrderAddressSnapshotDTO;
import com.chengcang.api.modules.sys.dto.SysProductDTO;
import com.chengcang.api.modules.sys.dto.orderSnapshotDTO.SysOrderProductSnapshotDTO;
import com.chengcang.api.modules.sys.vo.SysProductSeriesVo;
import com.mysql.cj.util.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BusiOrderVO implements Serializable{

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    private Long id;

    @ApiModelProperty(value = "客户外键")
    private Long tenantId;

    @ApiModelProperty(value = "甲方ID")
    private Long paId;

    @ApiModelProperty(value = "甲方name")
    private String paName;

    @ApiModelProperty(value = "订单编号")
    private String orderNo;

    @ApiModelProperty(value = "需求编号")
    private String demandNo;

    @ApiModelProperty(value = "订单金额")
    private BigDecimal totalAmount;

    @ApiModelProperty(value = "不含增值税金额")
    private BigDecimal noVatPrice;

    @ApiModelProperty(value = "增值税")
    private BigDecimal vat;

    @ApiModelProperty(value = "纯前端展示, 待履约已履约")
    private String singleShow = "待发货";

    @ApiModelProperty(value = "合同总价")
    private BigDecimal contractTotalPrice;

    @ApiModelProperty(value = "卖家收款金额")
    private BigDecimal sellerReceivePrice;

    @ApiModelProperty(value = "平台代收税费")
    private BigDecimal platformTakeTaxPrice;

    @ApiModelProperty(value = "单位")
    private Integer productUnit;

    @ApiModelProperty(value = "单位描述")
    private String productUnitName;

    @ApiModelProperty(value = "订单状态,0:待付款; 1:待发货; 2:已发货; 3:已完成; 4:已关闭")
    private Integer status;

    @ApiModelProperty(value = "订单状态描述")
    private String statusName;

    @ApiModelProperty(value = "支付状态")
    private Integer payStatus;

    @ApiModelProperty(value = "支付状态描述")
    private String payStatusName;

    @ApiModelProperty(value = "订单来源")
    private Integer sourceType;

    @ApiModelProperty(value = "订单来源描述")
    private String sourceTypeName;

    @ApiModelProperty(value = "订单类型")
    private Integer type;

    @ApiModelProperty(value = "订单类型描述")
    private String typeName;

    @ApiModelProperty(value = "需求方ID")
    private Long demandId;

    @ApiModelProperty(value = "需求方名字")
    private String demandName;

    @ApiModelProperty(value = "供应方ID")
    private Long supplyId;

    @ApiModelProperty(value = "需求方名字")
    private String supplyName;

    @ApiModelProperty(value = "商品信息外键")
    private Long productId;

    @ApiModelProperty(value = "收货地址外键")
    private Long addressId;

    @ApiModelProperty(value = "地址")
    private BusiOrderAddressSnapshotDTO address;

    @ApiModelProperty(value = "发票抬头外键")
    private Long invoiceHeadId;

    @ApiModelProperty(value = "物流信息（车牌号）")
    private String deliveryInfo;

    @ApiModelProperty(value = "供应数量")
    private BigDecimal supplyNum;

    @ApiModelProperty(value = "过期时间")
    private Date demandExpire;

    @ApiModelProperty(value = "产品相关")
    private SysOrderProductSnapshotDTO productSeries;

    @ApiModelProperty(value = "创建人")
    private Long creator;

    @ApiModelProperty(value = "创建时间")
    private Date createDate;

    @ApiModelProperty(value = "更新人")
    private Long updater;

    @ApiModelProperty(value = "更新时间")
    private Date updateDate;

    @ApiModelProperty(value = "是否删除")
    private Integer deleted;

    public void setDeliveryInfo(String deliveryInfo){
        this.deliveryInfo = deliveryInfo;
        if(!StringUtils.isNullOrEmpty(deliveryInfo)){
            this.singleShow = "已发货";
        }
    }

    public void setStatus(Integer status){
        if(status == 1){
            this.singleShow = "已发货";
            this.statusName = "已发货";
        }
    }

}
